package org.bigmarketapi.projectreview.LUA;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @BelongsProject: Lottery
 * @BelongsPackage: com.example.infrastructure.utils
 * @Author: dujiaqi
 * @CreateTime: 2024-02-22  21:42
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
public class MyRedissonConfig {
    /**
     * 对 Redisson 的使用都是通过 RedissonClient 对象
     *
     * @return
     */
    @Bean(destroyMethod = "shutdown") // 服务停止后调用 shutdown 方法。
    public RedissonClient redisson() throws IOException {
        Config config = new Config();
        config.setCodec(JsonJacksonCodec.INSTANCE);
        config.useSingleServer().setAddress("redis://127.0.0.1:6379")
                .setPassword("djq@123");
        // 创建RedissonClient对象
        return Redisson.create(config);
    }
}

